<?php
/**
 * 招生信息管理类
 * @author 肖小平
 *
 */
class RecruitmentAction extends BaseAction{
	/**
	 * 招生信息列表
	 */
	public function recruitment_list(){
		$where = "ac_id=14";
		$where .= $this->my_where();
		import('ORG.Util.Page');// 导入分页类
		$count = M('Article')->where($where)->count();//总条数
		$Page = new Page($count,10);//每页显示10条
		$show = $Page->show();
		$list = M('Article')->where($where)->order('sort')->limit($Page->firstRow.','.$Page->listRows)->select();
		$this->assign("list",$list);
		$this->assign('page',$show);// 赋值分页输出
		$this->display();
	}
	public function recruitment_add(){
		if($_POST){
			$_POST['time'] = time();
			$_POST['ac_id'] = 14;
			$_POST['visits'] = 0;
			$_POST['content'] = stripslashes($_POST['content']);
			M('Article')->add($_POST);
			$this->success('添加成功',U('Recruitment/recruitment_list'));
			exit;
		}
		$this->display();
	}
	/**
	 * 招生信息修改
	 */
	public function recruitment_update(){
		if ($_POST){
			$_POST['content'] = stripslashes($_POST['content']);
			M('Article')->save($_POST);
			$this->success('更新成功',U('Recruitment/recruitment_list',array('p'=>$_POST['p'],'search_word'=>$_POST['search_word'])));
			exit;
		}
		$search_word = $_GET['search_word'];//控制修改信息后返回修改的当前位置
		$p = $_GET['p'];//控制修改信息后返回修改的当前页面
		$obj = M('Article')->where("id=".$_GET['id'])->find();
		$this->assign("obj",$obj);
		$this->assign('p',$p);
		$this->assign('search_word',$search_word);
		$this->display();
	}
	/**
	 * 删除招生信息
	 */
	public function recruitment_delete(){
		M('Article')->where("id=".$_GET['id'])->delete();
		$this->success('删除成功');
	}
	//搜索配置
	public function my_where(){
		$where = '';
		$search_word = $_GET['search_word'];
		if($search_word) {
			$where .= " and (title like '%$search_word%') ";
		}
		return $where;
	}
}

?>